package com.tim.app.server.net;

import android.text.TextUtils;

import com.tim.app.RT;
import com.tim.app.server.logic.UserManager;


/**
 * @author fanxiaofeng
 * @date 2016年3月28日
 * 动态域名
 */
public class ServerAddressManager {

    private static final String DEFAULT_BASE_ADDRESS = "https://data.urmoli.com/";//默认的状态服务器地址

    private static String httpServerDomain = "";//http服务器地址

    public static String SHARE_DEFAULT_LOGO_URL = "http://moli2017.oss-cn-zhangjiakou.aliyuncs.com/20170701/logo.png";

    /**
     * 获取服务器状态的域名
     *
     * @return
     */
    public static String getServerStateDomain() {
        String stateServerDomain = "";
        switch (RT.HOST) {
            case DEVELOP:
//                stateServerDomain = "http://192.168.1.17:8086/";
//                stateServerDomain = " http://192.168.1.20:8030/";
                break;
            case DEBUG:
                stateServerDomain = "http://api.java.duailin.top/";
                break;
            case PUBLISH:
                stateServerDomain = DEFAULT_BASE_ADDRESS;
                break;
        }
        return stateServerDomain;
    }

    /**
     * 获取http服务器的域名
     *
     * @return
     */
    public static String getHttpServerDomain() {
        if (TextUtils.isEmpty(httpServerDomain)) {
            httpServerDomain = UserManager.ins().getHttpServerDomain();
        }
        return httpServerDomain;
    }

    /**
     * 重置域名
     */
    public static void resetDomain() {
        httpServerDomain = "";
        UserManager.ins().saveHttpServerDomain("");
    }

    /**
     * 更新域名
     */
    public static void updateDomain(String httpDomain) {
        httpServerDomain = httpDomain;
        UserManager.ins().saveHttpServerDomain(httpDomain);
    }

}
